from flask import render_template,flash,redirect,Flask,request,url_for
from app1 import app_start
from .forms import LoginForm
@app_start.route('/')
@app_start.route('/index')
def index():
    user={'nickname':'Miguel'}
    posts=[{
        'author':{'nickname':'John'},
        'body':'Beautiful day in Portland!'
        },
        {
            'author': {'nickname': 'Susan'},
            'body': 'The Avengers movies was so cool!'
        }]
    return render_template("index.html",
                           title='Home',
                           user=user,
                           posts=posts)

@app_start.route('/login',methods=['GET','POST'])
def login():
    form=LoginForm()
    if form.validate_on_submit():
        flash('Login requested for OpenID="' + form.openid.data + '", remember_me=' + str(form.remember_me.data))
        return redirect('/index')
    return render_template('login.html',
                           title='Sign in',
                           form=form,
                           providers=app_start.config['OPENID_PROVIDERS'])